home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.3 / Video Toaster v4.3.iso / 3.1 / toasterall / arexx_examples / tpaint / iff2tpaint.rexx < prev    next >
OS/2 REXX Batch file  |  1992-01-29  |  3KB  |  93 lines

  1. /* Map iff to ToasterPaint canvas */
  2. /* By Arnie Cachelin © 1992 NewTek Inc */
  3. /* 01 Dec 1991 At 23:07:52 */
  4.  
  5. /*
  6.   This program will load a standard Amiga IFF image, and map it to fill the
  7. ToasterPaint canvas.  Give it a full file name to load.  Optional
  8. parameters are an output name, to save the RGB image, and a blur switch.
  9. If there is any third parameter given, then Blur will be used, and the
  10. whole picture will be blurred once.  This helps smooth the pixels and color
  11. bands in lower resolution or color images.  To turn the blur on without
  12. saving the frame, use 'NIL:' as your save name.
  13.  */
  14.  
  15. ARG iffname outname blur
  16.  
  17. Address "DigiPaint"     /* Tell ARexx where commands go  */
  18.  
  19. if pos('DigiPaint',show(ports))=0 then do
  20.   say "Can't find ToasterPaint!"
  21.   exit
  22.   end
  23.  
  24. PageWide=752
  25. PageHigh=480
  26. 'Bdel'                /* Delete swap brush */
  27. Call LoadBrush(iffname)
  28. 'Bcop'                /* Copy Brush to swap brush */
  29. 'Maxe'                /* Set edge blend level to max */
  30. 'Maxc'                /* Set center blend level to max */
  31. 'Cbx0'                /* Choose color 0 (black) */
  32. 'Clrs'                /* Clear the screen */
  33. Call MapBrush(0,0,PageWide,PageHigh)
  34. if Blur~="" Then do
  35.     'Blur'
  36.     'Redo'
  37.     end
  38. if Outname~="" & OutName~="NIL:" then do
  39.     Call SaveRGB(outname)
  40.     end
  41. 'Shco'
  42. exit
  43.  
  44. MapBrush: PROCEDURE  /* Size swap brush into rectangle with corners at (x1,y1) and (x2,y2) */
  45.   arg x1, y1, x2, y2 /* if there is no swap brush, whole screen is used! */
  46.   'Pmcl'        /* Normal draw Mode */
  47.     'Hvof'                /* Turn off gradient blend (center=edge) */
  48.     'Maxc'                /* Set transparency off */
  49.   'Flon'        /* Fill On */
  50.   'Aaon'        /* Anti-alias on */
  51.   'Txma'        /* Texture mapping on, fill on, draw rectangles  */
  52.   'Drre'        /* Draw Rectangles */
  53.   'Pend' x1 y1  /* Get in top Left corner  */
  54.   'Penu' x2 y2  /* lift pen  */
  55.   'Flof'        /* fill off  */
  56.   'Pmcl'        /* Normal draw Mode */
  57.   return
  58.  
  59. SetFile: PROCEDURE           /* Select file in current requester */
  60.   arg file
  61.   dirname=GetPathName(file)
  62.   'Dnam'dirname          /* Enter file path  */
  63.   'Dsel'                 /* Hit return on directory */
  64.   filename=GetFileName(file)
  65.   'Fnam'filename         /* Enter File name  */
  66.   'Okls'                 /* Hit the OK button  */
  67.   return
  68.  
  69. SaveRGB: PROCEDURE   /* Load Brush, copy into swap buffer */
  70.   arg filename
  71.   'Sa24'                 /* Call file requester  */
  72.     Call SetFile(filename)
  73.   return
  74.  
  75. LoadBrush: PROCEDURE   /* Load Brush */
  76.   arg filename
  77.   'Lobr'                 /* Call file requester  */
  78.     Call SetFile(filename)
  79.   return
  80.  
  81. GetFileName: procedure  /* Extract file name from full file specification */
  82.    ARG fullfile
  83.    c = lastpos("/",fullfile)
  84.    if c = 0 then c = lastpos(":",fullfile)
  85.    return substr(fullfile, c + 1)
  86.  
  87. GetPathName: procedure  /* Extract directory name from full file specification */
  88.    ARG fullfile
  89.    c = lastpos("/",fullfile)
  90.    if c = 0 then c = lastpos(":",fullfile)
  91.    return left(fullfile,c)
  92.  
  93.